﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KMFrame.Permission.BLL;

namespace WebSite.admin.users
{
    public partial class useradd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Groups gbll = new Groups();
                IEnumerable<Groups.GroupInfo> glist = gbll.GetGroupInfoList();
                foreach (Groups.GroupInfo g in glist)
                {
                    ListItem item = new ListItem(g.GroupName, g.GroupID.ToString());
                    this.UserAdd_usergroup.Items.Add(item);
                }
                this.UserAdd_status.SelectedValue = "1";
            }
            else
            {
                UserInfo user = new UserInfo();
                user.UserName = Request.Form["UserAdd_username"];
                user.Email = Request.Form["UserAdd_email"];
                user.UserGroup = int.Parse(Request.Form["UserAdd_usergroup"]);
                user.Status = int.Parse(Request.Form["UserAdd_status"]);

                Users ubll = new Users();
                ubll.CreateUser(user);
                Response.End();
            }
        }
    }
}